package org.vast.ows.sps;

import org.vast.cdm.common.CDMException;
import org.vast.ogc.OGCRegistry;
import org.vast.ows.AbstractResponseWriter;
import org.vast.ows.OWSException;
import org.vast.xml.DOMHelper;
import org.w3c.dom.Element;

public class CancelResponseWriterV20 extends AbstractResponseWriter<CancelResponse>
{
	protected SPSCommonWriterV20 commonWriter = new SPSCommonWriterV20();
	

	@Override
	public Element buildXMLResponse(DOMHelper dom, CancelResponse response,
			String version) throws OWSException {
		// TODO Auto-generated method stub
		try
		{
			dom.addUserPrefix("sps", OGCRegistry.getNamespaceURI(SPSUtils.SPS, version));
			
			// root element
			Element rootElt = dom.createElement("sps:" + response.getMessageType());
					
			// status report
			Element reportElt = commonWriter.writeStatusReport(dom, response.getStatusReport());
			Element resElt = dom.addElement(rootElt, "sps:result");
			resElt.appendChild(reportElt);
			
			return rootElt;
		}
		catch (CDMException e)
		{
			throw new SPSException(e);
		}
	}
}
